﻿using System.Collections.Generic;
using System.IO;

namespace App_Code
{
    /// <summary>
    /// Summary description for IconRepository
    /// </summary>
    /// 
   
    public static class IconRepository
    {
        static readonly Dictionary<string, string> _images = new Dictionary<string, string>();
        static public void TemplateLoader(System.Web.UI.Page page)
        {
            lock (_images)
            {
                if (_images.Count != 0)
                    return;
                string iconFolder = page.Server.MapPath("icons");
                string[] files = Directory.GetFiles(iconFolder, "*.png");
                foreach (var text in files)
                {
                    _images.Add(""+Path.GetFileName(text), text);
                }
            }
        }

        static public string Restaurant(int scale)
        {
            string restaurantKey = "nf" + scale + ".png";

            string fullPath;
            if (_images.TryGetValue(restaurantKey, out fullPath))
            {
                return fullPath;
            }

            return null;
        }

        static public string Temple(int scale)
        {
            string restaurantKey = "tm" + scale + ".png";

            string fullPath;
            if (_images.TryGetValue(restaurantKey, out fullPath))
            {
                return fullPath;
            }

            return null;
        }
    }
}